home *** CD-ROM | disk | FTP | other *** search
- Path: news.th-darmstadt.de!news
- From: Enno Sandner <enno@intellektik.informatik.th-darmstadt.de>
- Newsgroups: comp.lang.c++
- Subject: Re: Templates & friends
- Date: Mon, 15 Apr 1996 13:06:26 +0200
- Organization: Fachbereich Informatik, TH Darmstadt
- Message-ID: <31722DB2.237C228A@intellektik.informatik.th-darmstadt.de>
- References: <317211BF.41C6@sonytel.be>
- NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.01 (X11; I; SunOS 4.1.3 sun4m)
-
- Philip Rademakers wrote:
- >
- > Hi,
- >
- > Does anybody know how to declare a friend class that is one of the
- > argument classes? I tried the following:
- >
- > class X {
- > protected:
- > X();
- > };
- >
- > template<class T>
- > class foo {
- > private:
- > T* _ptr;
- > public:
- > friend class T;
- > foo() { _ptr = new T; }
- > };
- >
- > The compiler (on SGI) complains that X::X() is not accessible ?
- >
-
- Friendship is not symmetrical, i.e. the instance foo<X> of the
- generic class declares 'X' as friend of the 'foo<X>' but not
- vice versa. Thus 'foo<X>' cannot access non-public parts of
- class 'X'.
-
- Enno
-